#include <queue>
using namespace std;

class MyStack
{
public:
    MyStack()
    {
    }

    void push(int x)
    {
        _que.push(x);
    }

    int pop()
    {
        size_t size = _que.size();
        size--;
        while (size--)
        {
            _que.push(_que.front());
            _que.pop();
        }
        int result = _que.front();
        _que.pop();
        return result;
    }

    int top()
    {
        return _que.back();
    }

    bool empty()
    {
        return _que.empty();
    }

private:
    queue<int> _que;
};

/**
 * Your MyStack object will be instantiated and called as such:
 * MyStack* obj = new MyStack();
 * obj->push(x);
 * int param_2 = obj->pop();
 * int param_3 = obj->top();
 * bool param_4 = obj->empty();
 */